package coderead.plugin.ui;

import com.intellij.ui.SimpleTextAttributes;
import com.intellij.util.ui.UIUtil;

import static com.intellij.ui.SimpleTextAttributes.*;
import static com.intellij.ui.SimpleTextAttributes.STYLE_SEARCH_MATCH;

public class StyleText {
    public static final SimpleTextAttributes searchMatchMainStyle;
    public static SimpleTextAttributes searchMatchSubStyle;

    static {
        searchMatchMainStyle = new SimpleTextAttributes(STYLE_PLAIN | STYLE_SEARCH_MATCH, null);
        searchMatchSubStyle = new SimpleTextAttributes(STYLE_SMALLER | STYLE_SEARCH_MATCH, UIUtil.getInactiveTextColor());
    }
    public String text;
    public SimpleTextAttributes style;
    public boolean isMain;

    public StyleText(String text, SimpleTextAttributes style, boolean isMain) {
        this.text = text;
        this.style = style;
        this.isMain = isMain;
    }

    public boolean merge(StyleText styleText) {
        if (style.equals(styleText.style) && isMain == styleText.isMain) {
            text += styleText.text;
            return true;
        }
        return false;
    }
}